package management.system.utils;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

public class Utils {

	

public static boolean saveImage(InputStream input, String fileName) {
    FileOutputStream output = null;
    boolean ok = false;
    try {
    	System.out.println("path utils:"+fileName);
        output = new FileOutputStream(fileName);
        int leido = 0;
        leido = input.read();
        while (leido != -1) {
            output.write(leido);
            leido = input.read();
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(ex.getMessage());
    } catch (IOException ex) {
    	ex.printStackTrace();
    } finally {
        try {
            output.flush();
            output.close();
            input.close();
            ok = true;
        } catch (IOException ex) {
        	ex.printStackTrace();
        }
    }
    return ok;
}
}
